package com.nmsl.registration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.nmsl.registration.domain.skxIndex;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.registration.domain.skxRegistrationManagement;
import com.nmsl.registration.service.skxIRegistrationManagementService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 工作台Controller
 * 
 * @author sn
 * @date 2025-02-14
 */

@RestController
@RequestMapping("/skx/management")
public class skxRegistrationManagementController extends BaseController
{
    @Autowired
    private skxIRegistrationManagementService registrationManagementService;

    /**
     * 查询工作台列表
     */
    @PreAuthorize("@ss.hasPermi('sn:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(skxRegistrationManagement skxRegistrationManagement)
    {
        startPage();
        List<skxRegistrationManagement> list = registrationManagementService.selectRegistrationManagementList(skxRegistrationManagement);
        return getDataTable(list);
    }

    /**
     * 导出工作台列表
     */
    @PreAuthorize("@ss.hasPermi('sn:management:export')")
    @Log(title = "工作台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, skxRegistrationManagement skxRegistrationManagement)
    {
        List<skxRegistrationManagement> list = registrationManagementService.selectRegistrationManagementList(skxRegistrationManagement);
        ExcelUtil<skxRegistrationManagement> util = new ExcelUtil<skxRegistrationManagement>(skxRegistrationManagement.class);
        util.exportExcel(response, list, "工作台数据");
    }

    /**
     * 获取工作台详细信息
     */
    @PreAuthorize("@ss.hasPermi('sn:management:query')")
    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return success(registrationManagementService.selectRegistrationManagementByRegistrationId(registrationId));
    }

    /**
     * 新增工作台
     */
    @PreAuthorize("@ss.hasPermi('sn:management:add')")
    @Log(title = "工作台", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody skxRegistrationManagement skxRegistrationManagement)
    {
        return toAjax(registrationManagementService.addRegistrationManagement(skxRegistrationManagement));
    }

    /**
     * 修改工作台
     */
    @PreAuthorize("@ss.hasPermi('sn:management:edit')")
    @Log(title = "工作台", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody skxRegistrationManagement skxRegistrationManagement)
    {
        return toAjax(registrationManagementService.updateRegistration(skxRegistrationManagement));
    }

    /**
     * 删除工作台
     */
    @PreAuthorize("@ss.hasPermi('sn:management:remove')")
    @Log(title = "工作台", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationIds}")
    public AjaxResult remove(@PathVariable Long[] registrationIds)
    {
        return toAjax(registrationManagementService.deleteRegistrationManagementByRegistrationIds(registrationIds));
    }

    @PreAuthorize("@ss.hasPermi('registration:management:list')")
    @GetMapping("/getList")
    public TableDataInfo getList(){
        startPage();
        List<skxRegistrationManagement> list = registrationManagementService.getRegistrationManagementList();
        return getDataTable(list);

    }


//    @PreAuthorize("@ss.hasPermi('registration:management:getlist')")
    @GetMapping("/getListbyindex")
    public TableDataInfo getListbyindex(skxIndex skxIndex){
        startPage();
        List<skxRegistrationManagement> list = registrationManagementService.getRegistrationManagementListByIndex(skxIndex);
        return getDataTable(list);

    }

}
